﻿using CPPEI.Coolzon.Designer.Views;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.Designtime
{
    public class DesignerTemplatePool : ITemplatePoll
    {
        public string[] GetTemplates()
        {
            List<string> templateList = new List<string>();

            Metadata.Solution dtSolution = UIContext.Current.CurrentSolution;

            for (int index = 0; index < dtSolution.Scenes.Count; index++)
            {
                Metadata.Scene scene = dtSolution.Scenes[index];
                Guid sceneID = Guid.Empty;
                if (UIContext.Current.CurrentEditedNode != null)
                {
                    sceneID = UIContext.Current.CurrentEditedNode.ID;
                }
                if (scene.ID == sceneID)
                {
                    if (scene.Templates != null && scene.Templates.Count > 0)
                    {
                        for (int j = 0; j < scene.Templates.Count; j++)
                        {
                            templateList.Add(scene.Templates[j].Name);
                        }
                    }
                    break;
                }
            }
            return templateList.ToArray();
        }
    }
}
